home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / tcwind16 / winddemo.c < prev    next >
Text File  |  1987-07-24  |  36KB  |  1,050 lines

  1. #define MAIN 1
  2. #include <stdarg.h>
  3. #include <window.h>
  4. #include <stdio.h>
  5. #include <dos.h>
  6. #include <bios.h>
  7. #include <string.h>
  8. #include <alloc.h>
  9. #include <mem.h>
  10.  
  11.  
  12.  
  13.  
  14. char *opnmsg;
  15. char *endmsg;
  16. char *compmsg;
  17. char *pwndmsg;
  18. char *prtmsg;
  19. char *menu1;
  20.  
  21. main()
  22. {
  23.  int x;
  24.  
  25. pwndmsg=
  26.  "    CALL: pwindf(col,row,color,""format"",arguments);\n"
  27.  "\n   Prints a formated string in the current window, with col and row\n"
  28.  "offset with respect to the start of the window. This function will not\n"
  29.  "print outside of the window. If col is less than the left side then col\n"
  30.  "will=left side.  If col is greater then the right side col will=left side.\n"
  31.  "If the string is to long to fit within the window it will be truncated.\n"
  32.  "If the string has a backward slash <n> inbedded in it, the rest of the\n"
  33.  "string will be printed on the next line.\n"
  34.  "\n   If row is less then the top row then row=top row. If row is greater\n"
  35.  "then the bottom row then the window will scroll up to accomodate the new\n"
  36.  "string.\n"
  37.  "\n   Format can be any of the printf format qualifiers as listed in your\n"
  38.  "manual.\n";
  39.  
  40. compmsg=
  41.  "  These routines are supplied in LIBRARY format. There are five\n"
  42.  "different LIBRARY modules as listed below:\n"
  43.  "\nWINDS.LIB            Small   library module"
  44.  "\nWINDM.LIB            Medium  library module"
  45.  "\nWINDC.LIB            Compact library module"
  46.  "\nWINDL.LIB            Large   libary module"
  47.  "\nWINDH.LIB            Huge    library module\n"
  48.  "\n  To use these routines link the module you wish to use with your\n"
  49.  "program. The easiest way is to use the PROJECT capabilities of Turbo C.\n"
  50.  "Be sure to use the correct LIBRARY MODULE for your application.\n"
  51.  "\nOne of the sample programs supplied with Turbo C is an OBJECT MODULE\n"
  52.  "called MCMVSMEM.OBJ this is a fast screen write utilitiy. This module\n"
  53.  "must also be linked with your program as these window routines make\n"
  54.  "extensive use of this function.\n"
  55.  "\n  You must also include header file WINDOW.H in your program. This file\n"
  56.  "has the needed defines and function prototypes in it.";
  57.  
  58. endmsg=
  59.  "  These routines have been tested on a TANDY 1000A, PC LIMITED 286\n"
  60.  "EGA unit and an IBM XT. They should work with any CGA,EGA  PC\n"
  61.  "compatible computer. These have not been tested on a MONO system.\n"
  62.  "\n  If you are having any trouble getting these routines to work on\n"
  63.  "other machines, Please let me know and I will do what I can to help you\n"
  64.  "solve the problem.\n"
  65.  "\n  While these function have some error checking built in. It\n"
  66.  "is the programers responsibility to ensure correct usage.\n"
  67.  "\n If you have questions or comments you can reach me via mail on\n"
  68.  "                  GENIE:  D. R. Evans\n"
  69.  "\n While it is not necessary to have the source code to use the routines\n"
  70.  "in this package, you may purchase this code by sending $20.00  and your\n"
  71.  "return address to:\n"
  72.  "                  Daniel R. Evans\n"
  73.  "                  1902 Broughton Dr.\n"
  74.  "                  Beverly, MA 01915";
  75.  
  76.  
  77.  opnmsg=
  78.   "  Included in this package are all the routines for memory models,\n"
  79.   "SMALL-MEDIUM-COMPACT-LARGE-HUGE. To use these routines you will need\n"
  80.   "the fast screen write utility supplied with Turbo C called MCMVSMEM.OBJ.\n"
  81.   "\n  You are free to use these routines in any software you write, either\n"
  82.   "for your own use or to sell without a fee of any kind. You may distribute\n"
  83.   "these routines as long as the package remains intact. You may not charge\n"
  84.   "more then a reasonable duplication fee. You may not sell this package as\n"
  85.   "part of or as any kind of windowing software."
  86.   "\n             There are 19 functions with this package.\n"
  87.   "initwindow          clrscr          setcursor            screenmode\n"
  88.   "clrwind             mbox            mline                attr\n"
  89.   "mwind               rwind           wtitle               movwind\n"
  90.   "pwindf              pwindfc         gowindcr             waitkey\n"
  91.   "pullmenu            popupmenu       keyin\n"
  92.   "\n  When you have finished with the pull menu, use ESC to exit";
  93.  
  94.  
  95.  initwindow();
  96.  screenmode(color80);
  97.  clrscr(attr(white,blue),red);
  98.  setcursor(off);
  99.  shadow=FALSE;
  100.  bordercolor=attr(yellow,red);
  101.  windowcolor=attr(white,blue);
  102.  for(x=0;x<79;x+=10)
  103.    mline(x,0,24,windowcolor,vert,sglline);
  104.  for(x=0;x<24;x+=3)
  105.    mline(0,x,79,windowcolor,hornz,sldline);
  106.  mwind(10,9,70,13,attr(yellow,blue),attr(yellow,red),sldbrdr);
  107.  pwindfc(1,attr(white,blue),"Window routines 1.6 for BORLAND'S Turbo C");
  108.  pwindfc(2,attr(white,blue),"By D.R. EVANS Copywrite (C) 1987");
  109.  sleep(2);
  110.  rwind();
  111.  clrscr(attr(white,black),black);
  112.  godomenu();
  113.  shprint();
  114.  expcomp();
  115.  enddemo();
  116.  for(x=currentwind;x>0;x--)
  117.    rwind();
  118.  setcursor(on);
  119.  screenmode(color80);
  120.  clrscr(attr(white,black),black);
  121. }
  122.  
  123.  
  124. godomenu()
  125. {
  126. char index;
  127.  pullmainmenu[0]=
  128.   "inTro\n"
  129.   "Initilize\n"
  130.   "Screen\n"
  131.   "Windows\n"
  132.   "Printing\n"
  133.   "pOp Wind\n"
  134.   "Next Menu\n"
  135.   "TISWPON\n";
  136.  
  137.  pullsubmenu[0][2]=
  138.   "Clearing Screen      \n"
  139.   "Clearing Window      \n"
  140.   "Setting Screen Mode  \n"
  141.   "Turning Cursor ON/OFF\n"
  142.   "Assigning Colors     \n"
  143.   "SWMTA\n";
  144.  
  145.  pullsubmenu[0][3]=
  146.  "Making A Window  \n"
  147.  "Removing A Window\n"
  148.  "Moving Windows   \n"
  149.  "Adding A Title   \n"
  150.  "Border Selection \n"
  151.  "MRWAB\n";
  152.  
  153.  pullsubmenu[0][4]=
  154.   "Formatted Window Printing         \n"
  155.   "Centered Formatted Window Printing\n"
  156.   "Going to a COL/ROW                \n"
  157.   "FCG\n";
  158.  
  159.  pullsubmenu[0][5]=
  160.  " Menu Operation     \n"
  161.  " Popupmenu Syntax   \n"
  162.  " Defining a Menu    \n"
  163.  " Menu Return Code   \n"
  164.  " Use of Return Code \n"
  165.  " How to EXIT Menu   \n"
  166.  "MPDRUE\n";
  167.  
  168.  
  169.  
  170.  pullmainmenu[1]=
  171.  "Pull Menu\n"
  172.  "Key input\n"
  173.  "Sp Effect\n"
  174.  "Line Draw\n"
  175.  "Box Draw\n"
  176.  "Global Var\n"
  177.  "Prev Menu\n"
  178.  "PKSLBGM\n";
  179.  
  180.  pullsubmenu[1][0]=
  181.  "Menu Operation      \n"
  182.  "Pullmenu Syntax     \n"
  183.  "Defining a Menu     \n"
  184.  "Menu Return Code    \n"
  185.  "Use of Return Code  \n"
  186.  "How to EXIT Menu    \n"
  187.  "MPDRUE\n";
  188.  
  189.    while((index = pullmenu(TOP,0)) !=NULL) {
  190.       switch(pullmenuloc)
  191.       {
  192.          case 0:
  193.             mwind(2,0,77,23,windowcolor,bordercolor,dblbrdr);
  194.             pwindfc(0,windowcolor,"Window Routines 1.6 for BORLAND'S TURBO C");
  195.             pwindfc(1,windowcolor,"By D.R. Evans Copywrite (C) 1987");
  196.             pwindf(0,3,windowcolor,"%s",opnmsg);
  197.             waitkey(PRET);
  198.             rwind();
  199.             break;
  200.          case 1:
  201.             shinitwindow();
  202.             rwind();
  203.             shscroll();
  204.             rwind();
  205.             break;
  206.  
  207.          case 2:
  208.             switch(index)
  209.             {
  210.                case 'S':
  211.                   shclrscr();
  212.                   rwind();
  213.                   break;
  214.                case 'W':
  215.                   shclrwind();
  216.                   rwind();
  217.                   break;
  218.                case 'M':
  219.                   shscreenmode();
  220.                   rwind();
  221.                   break;
  222.                case 'T':
  223.                   shsetcursor();
  224.                   rwind();
  225.                   break;
  226.                case 'A':
  227.                   shattr();
  228.                   rwind();
  229.                   break;
  230.             }
  231.             break;
  232.          case 3:
  233.             switch(index)
  234.             {
  235.                case 'M':
  236.                   shmwind();
  237.                   rwind();
  238.                   break;
  239.                case 'R':
  240.                   shrwind();
  241.                   rwind();
  242.                   break;
  243.                case 'W':
  244.                   shmove();
  245.                   rwind();
  246.                   break;
  247.                case 'A':
  248.                   shtitle();
  249.                   rwind();
  250.                   break;
  251.                case 'B':
  252.                   shborders();
  253.                   break;
  254.             }
  255.             break;
  256.          case 4:
  257.             switch(index)
  258.             {
  259.                case 'F':
  260.                   shpwindf();
  261.                   rwind();
  262.                   break;
  263.                case 'C':
  264.                   shpwindfc();
  265.                   rwind();
  266.                   break;
  267.                case 'G':
  268.                   shgowind();
  269.                   rwind();
  270.                   break;
  271.             }
  272.             break;
  273.          case 5:
  274.             shpopup(index);
  275.             break;
  276.          case 6:
  277.             while((index = pullmenu(TOP,1)) != NULL) {
  278.                switch(pullmenuloc)
  279.                {
  280.                   case 0:
  281.                      shpullmenu(index);
  282.                      break;
  283.                   case 1:
  284.                      shwait();
  285.                      rwind();
  286.                      break;
  287.                   case 2:
  288.                      shshadow();
  289.                      rwind();
  290.                      break;
  291.                   case 3:
  292.                      shmline();
  293.                      rwind();
  294.                      break;
  295.                   case 4:
  296.                      shmbox();
  297.                      rwind();
  298.                      break;
  299.                   case 5:
  300.                      shglobal();
  301.                      rwind();
  302.                      break;
  303.                   case 6:
  304.                      index = NULL;
  305.                   break;
  306.                }
  307.                if(index == NULL)
  308.                   break;
  309.             }
  310.       }
  311.    }
  312. }
  313.  
  314.  
  315. shpopup(char index)
  316. {
  317. char *popsyn,*menudef,*exitdef,*opdef,*retcdef,*usedef;
  318.  
  319.  usedef=
  320.   "  This is one way to use the character returned from the popupmenu\n"
  321.   "function. This is part of the routine used in this program\n"
  322.   "\nchar index;\n"
  323.   "\nwhile((index = popupmenu(10,5,menu1,dblbrdr) != NULL)\n"
  324.   " rwind();      \\* Remove the popupwindow !!! popup does not remove !!!*\\\n"
  325.   " switch(index)\n"
  326.   " {\n"
  327.   "   case 'P':\n"
  328.   "     mwind(0,11,79,23,windowcolor,bordercolor,sldbrdr);\n"
  329.   "     wtitle(CENTER,TOP,bordercolor,\" POPUPMENU SYNTAX \");\n"
  330.   "     pwindfc(0,windowcolor,\"CALLING CONVENTION\");\n"
  331.   "     pwindf(0,1,windowcolor,\"%s\",popsyn);\n"
  332.   "     waitkey(PRET);\n"
  333.   "     rwind();\n"
  334.   "     break;\n"
  335.   " }\n"
  336.   "}\n";
  337.  
  338.   retcdef=
  339.    "   The popup menu routine returns to the calling function with\n"
  340.    "the character of the menu item you selected.\n"
  341.    "   For example if you select Defining a Menu the \"D\" is returned\n"
  342.    "to the calling function";
  343.  
  344.   opdef=
  345.    "  To operate the menu, you use the up or down arrow keys\n"
  346.    "to move the hilited bar and the enter key to make the hilited\n"
  347.    "selection. You may also enter the hilited character to make\n"
  348.    "your selection.";
  349.  
  350.   exitdef=
  351.    "  If you hit \" ESC \" you will return to the calling function\n"
  352.    "with the return value of NULL.";
  353.  
  354.   popsyn =
  355.         "popupmenu(col, row, menu, bordtype);\n"
  356.         "\n WHERE:\n"
  357.         "         col and row are the upper left hand corner of the window\n"
  358.         "         Menu name is a pointer to a string (Explained in Menu Definition)\n"
  359.         "         Windowcolor is defined by the global variable plcolor\n"
  360.         "         Bordercolor is defined by the global variable pbrdcolor\n"
  361.         "         Selectable Character is defined by the global variable pletcolor\n"
  362.         "         Bordertype is the type of border around the window,same as mwind()\n";
  363.   menudef=
  364.         "Declare a pointer variable to a string.\n"
  365.         "char *menu1;   \\* set up pointer *\\\n"
  366.         "menu1 =                     Initilize pointer.\n"
  367.         " \" MAIN MENU \\n\"             In the first line define the title,displayed\n"
  368.         " \"Menu Operation      \\n\"  on the top border. On the next line, start\n"
  369.         " \"Defining a Menu     \\n\"  defining the menu selections. You can have up\n"
  370.         " \"PopUpMenu Syntax    \\n\"  to 20 menu selections in one window. All of the\n"
  371.         " \"Menu Return Code    \\n\"  menu selections must be the same length.\n"
  372.         " \"Use of Return Code  \\n\"    The popup menu routine checks the first menu\n"
  373.         " \"How to EXIT Menu    \\n\"  selection after the title, and uses this\n"
  374.         " \"MDPRUE\\n\";               length to decide the width of the menu.\n"
  375.         "                              if the length = 1 i.e.\" \\n\" no title is used"
  376.         "\n  The last line of menu definition defines the characters that\n"
  377.         "can be directly entered to select an item from the menu, these must\n"
  378.         "be all CAPS. All the characters in this last line must also be\n"
  379.         "distinct. The coresponding letter in each menu selection must also\n"
  380.         "be in CAPS.\n"
  381.         "\n  For example the last line in this menu is \"MDPRUE\" this\n"
  382.         "coresponds to the P in \"PopUpMenu Syntax\", the D in \"Defining Menu\",\n"
  383.         "the M in \"Menu Operation\", the R in \"Menu Return Code\" and ....\n";
  384.  
  385.     switch(index)
  386.     {
  387.       case 'P':
  388.         mwind(0,11,79,23,windowcolor,bordercolor,sldbrdr);
  389.         wtitle(CENTER,TOP,bordercolor," POPUPMENU SYNTAX ");
  390.         pwindfc(0,windowcolor,"CALLING CONVENTION");
  391.         pwindf(0,1,windowcolor,"%s",popsyn);
  392.         waitkey(PRET);
  393.         rwind();
  394.         break;
  395.       case 'D':
  396.         mwind(0,0,79,24,windowcolor,bordercolor,sldbrdr);
  397.         wtitle(CENTER,TOP,bordercolor," MENU DEFINITION ");
  398.         pwindfc(0,windowcolor,"MENU SETUP");
  399.         pwindf(0,1,windowcolor,"%s",menudef);
  400.         waitkey(PRET);
  401.         rwind();
  402.         break;
  403.       case 'M':
  404.         mwind(0,9,79,16,windowcolor,bordercolor,sldbrdr);
  405.         wtitle(CENTER,TOP,bordercolor," OPERATING MENU ");
  406.         pwindf(0,1,windowcolor,"%s",opdef);
  407.         waitkey(PRET);
  408.         rwind();
  409.         break;
  410.       case 'R':
  411.         mwind(0,9,79,16,windowcolor,bordercolor,sldbrdr);
  412.         wtitle(CENTER,TOP,bordercolor," RETURN CODE ");
  413.         pwindf(0,1,windowcolor,"%s",retcdef);
  414.         waitkey(PRET);
  415.         rwind();
  416.         break;
  417.       case 'U':
  418.         mwind(0,0,79,24,windowcolor,bordercolor,sldbrdr);
  419.         wtitle(CENTER,TOP,bordercolor," PROGRAM SETUP ");
  420.         pwindf(0,1,windowcolor,"%s",usedef);
  421.         waitkey(PRET);
  422.         rwind();
  423.         break;
  424.       case 'E':
  425.         mwind(0,10,79,14,windowcolor,bordercolor,sldbrdr);
  426.         wtitle(CENTER,TOP,bordercolor," EXITING MENU ");
  427.         pwindfc(0,windowcolor,"EXITING MENU WITHOUT A SELECTION");
  428.         pwindf(0,1,windowcolor,"%s",exitdef);
  429.         waitkey(PRET);
  430.         rwind();
  431.         break;
  432.     }
  433. }
  434.  
  435. shwait()
  436. {
  437. char *shwaitmsg,*shwaitmsg1,*shwaitmsg2,*shwaitmsg3;
  438. shwaitmsg=
  439.  " CALL: waitkey(PRET or MORE);\n"
  440.  "\n  If waitkey is called with MORE,\n"
  441.  "than a blinking - MORE - is printed\n"
  442.  "on the bottom border. The program\n"
  443.  "halts and waits for a key to be pressed\n";
  444. shwaitmsg1=
  445.  "\n  If waitkey is called with\n"
  446.  "PRET, than PRESS ENTER is printed\n"
  447.  "on the bottom border. The program\n"
  448.  "halts and waits for a key to be\n"
  449.  "pressed.\n";
  450. shwaitmsg2=
  451.  "\n  You can use the MORE qualifier\n"
  452.  "when you are going to scroll additional\n"
  453.  "information on the screen\n";
  454. shwaitmsg3=
  455.  "\n  You can use the PRET qualifier\n"
  456.  "when you are finished\n";
  457.  mwind(20,7,61,16,attr(yellow,blue),attr(yellow,red),sldbrdr);
  458.  wtitle(center,top,bordercolor," WAITKEY ");
  459.  pwindf(0,1,attr(yellow,blue),"%s",shwaitmsg);
  460.  waitkey(MORE);
  461.  pwindf(0,rowend,attr(yellow,blue),"%s",shwaitmsg1);
  462.  waitkey(PRET);
  463.  pwindf(0,rowend,attr(yellow,blue),"%s",shwaitmsg2);
  464.  waitkey(MORE);
  465.  pwindf(0,rowend,attr(yellow,blue),"%s",shwaitmsg3);
  466.  waitkey(PRET);
  467. }
  468.  
  469. shglobal()
  470. {
  471. char *shgbmsg,*shgbmsg1,*shgbmsg2;
  472.  shgbmsg=
  473.   "  There are eight global variables and one\n"
  474.   "Definition that you need to be aware of.\n"
  475.   "\nsnow:      If snow = TRUE then snow suppresion used for all routines.\n"
  476.   "           WSNOW is assigned as an enviromental variable,\n"
  477.   "           initwindow() checks the enviroment for WSNOW=remove.\n"
  478.   "           if this exists it uses snow suppresion else snow defaults\n"
  479.   "           to FALSE. This can be overridden by assigning snow=TRUE after\n"
  480.   "           the call to initwindow();\n"
  481.   "\nshadow:    If shadow = TRUE all windows displayed after this assignment\n"
  482.   "           will have shadows. initwindow() sets this to FALSE.\n"
  483.   "\nwindowcolor:\n"
  484.   "bordercolor:\n"
  485.   "             These two variables are convienent when you want to display\n"
  486.   "           a number of windows with the same default colors. You assign\n"
  487.   "           them to a color with the attr function\n"
  488.   "           i.e. windowcolor = attr(yellow,blue);";
  489.  shgbmsg1 =
  490.   "\nplcolor:\n"
  491.   "             This variable is used to define the Pullwindow & Popwindow\n"
  492.   "           inside colors.\n"
  493.   "\nphicolor:\n"
  494.   "             This variable is used to define the color of the hilighted\n"
  495.   "           bar used in Pullwindow & Popwindow\n"
  496.   "\npletcolor:\n"
  497.   "             This variable is used to define the color of the hilighted\n"
  498.   "           character used in the Pullwindow & Popwindow routines\n"
  499.   "\npullmenuloc:\n"
  500.   "             This variable is set by the pull menu routine, to the \n"
  501.   "           location of the hilited bar (0-7). This can then be used \n"
  502.   "           in a switch statement.\n"
  503.   "\npullmainmenu[]:\n"
  504.   "             This is the Main Pull down menu pointer. You can have up to\n"
  505.   "           seven Main pull down menus. This pointer is set to NULL in the\n"
  506.   "           initwindow() routine.\n";
  507.   shgbmsg2=
  508.   "\npullsubmenu[][]:\n"
  509.   "             This pointer defines each sub menu. the first array is the\n"
  510.   "           same as the pullmainmenu[] pointer.  i.e. if pullmainmenu[0] \n"
  511.   "           then pullsubmenu[0][0] would define the first main menu and \n"
  512.   "           first sub menu.  You can have 1 sub menu for each item in a \n"
  513.   "           Main menu for a total of 49 sub menus\n"
  514.   "\nrowend:\n"
  515.   "             This variable is set to the bottom border by the make window\n"
  516.   "           routine. You then use this to print on the bottom line of the\n"
  517.   "           window, which causes the window to scroll. If you print on the\n"
  518.   "           last line the window will not scroll. You must use rowend as \n"
  519.   "           the row to print on for scrolling.\n"
  520.   "\nMAXWIND:   This define is in window.h, currently set for 30 windows.\n"
  521.   "           You should set this value to the number of windows your\n"
  522.   "           application expects to use. The initwindow(); routine uses\n"
  523.   "           this define to set up the arrays for the window routines\n"
  524.   "\n \n";
  525.  
  526.  mwind(0,0,79,24,attr(yellow,blue),attr(yellow,red),sldbrdr);
  527.  wtitle(center,top,bordercolor," GLOBAL VARIABLES");
  528.  pwindf(0,1,attr(yellow,blue),"%s",shgbmsg);
  529.  waitkey(MORE);
  530.  pwindf(0,rowend,attr(yellow,blue),"%s",shgbmsg1);
  531.  waitkey(MORE);
  532.  pwindf(0,rowend,attr(yellow,blue),"%s",shgbmsg2);
  533.  waitkey(PRET);
  534. }
  535.  
  536. shprint()
  537. {
  538. char *prtmsg;
  539.  prtmsg=
  540.   "                    LIST OF ALL WINDOW ROUTINES\n"
  541.   "\n  void initwindow(void);"
  542.   "\n  void clrscr(attr(FG,BG),border color);"
  543.   "\n  void clrwind(Background Color);"
  544.   "\n  void setcursor(ON or OFF);"
  545.   "\n  void screenmode(color80 or color40);"
  546.   "\n  int  attr(Foreground color,Background color);"
  547.   "\n  void mwind(Col, Row, Endcol, Endrow, WindowColor, BorderColor,Bordertype);"
  548.   "\n  void mbox(Col, Row, Endcol, Endrow, Bordercolor, Bordertype);"
  549.   "\n  void mline(Col, Row, windcolor, Length, Linedir, Linetype);"
  550.   "\n  void wtitle(Justify, Loc, attr(FG,BG), TITLE);"
  551.   "\n  void movwind(Newcol, Newrow);"
  552.   "\n  void rwind(void);"
  553.   "\n  void pwindfc(Row, attr(FG,BG), FORMAT, ARGUMENTS);"
  554.   "\n  void pwindf(Col, Row, attr(FG,BG), FORMAT, ARGUMENTS);"
  555.   "\n  void gowindcr(Col, Row);"
  556.   "\n  void waitkey(MORE or PRET);"
  557.   "\n  int keyin(void);"
  558.   "\n  char pullmenu(Loc, MenuNumber);"
  559.   "\n  char popupmenu(col, row, menu, bordertype);\n"
  560.   "\n If you have a printer hit the PRINT SCREEN key for a hard copy listing";
  561.  
  562.  mwind(0,0,79,24,attr(white,blue),attr(yellow,red),sglbrdr);
  563.  wtitle(center,top,attr(black,green)," PRINT ");
  564.  pwindf(0,1,attr(white,blue),"%s",prtmsg);
  565.  waitkey(PRET);
  566. }
  567.  
  568. enddemo()
  569. {
  570.  mwind(0,0,79,24,attr(white,blue),attr(yellow,red),sldbrdr);
  571.  pwindf(0,1,attr(white,blue),"%s",endmsg);
  572.  waitkey(PRET);
  573. }
  574.  
  575. expcomp()
  576. {
  577.  mwind(0,0,79,24,attr(white,blue),attr(yellow,red),sldbrdr);
  578.  wtitle(center,top,attr(black,green)," COMPILING ");
  579.  pwindf(0,1,attr(white,blue),"%s",compmsg);
  580.  waitkey(PRET);
  581. }
  582.  
  583.  
  584. shpwindfc()
  585. {
  586. char *pcwndmsg;
  587.  
  588. pcwndmsg=
  589.  "CALL: pwindfc(row,color,format,arguments);\n"
  590.  "\n   Prints a formatted string centered\n"
  591.  "in the current window at the row specified\n"
  592.  "\n   Format can be any of the printf format\n"
  593.  "qualifiers as listed in your manual.\n";
  594.  
  595.  mwind(15,5,65,19,attr(yellow,blue),attr(yellow,red),sldbrdr);
  596.  wtitle(center,top,attr(black,green)," PWINDFC ");
  597.  pwindfc(1,attr(yellow,blue),"%s",pcwndmsg);
  598.  waitkey(PRET);
  599. }
  600.  
  601. shpwindf()
  602. {
  603.  mwind(0,0,79,24,attr(cyan,black),attr(black,blue),dtpbrdr);
  604.  wtitle(center,top,attr(black,green)," PWINDF ");
  605.  pwindf(0,1,attr(cyan,black),"%s",pwndmsg);
  606.  waitkey(PRET);
  607. }
  608.  
  609. shmline()
  610. {
  611. char *mlinemsg;
  612. mlinemsg=
  613.  "       CALL: mline(col,row,length,color,linedir,linetype);\n"
  614.  "\nDraws a line on the screen starting at the col and row specified\n"
  615.  "and extending in linedir (hornz, vert) for length spaces. The line\n"
  616.  "will be drawn in the line type selected.\n"
  617.  "\nAvailable line types are double,single and solid.These are defined\n"
  618.  "in window.h";
  619.  
  620.  mwind(2,0,77,12,attr(cyan,black),attr(black,green),dtpbrdr);
  621.  wtitle(center,top,attr(black,green)," MLINE ");
  622.  pwindf(0,1,attr(yellow,black),"%s",mlinemsg);
  623.  waitkey(PRET);
  624. }
  625.  
  626. shmbox()
  627. {
  628. char *mboxmsg;
  629. mboxmsg=
  630.  "    CALL: mbox(col,row,endcol,endrow,bordercolor,bordertype);\n"
  631.  "\nDraws a box on the screen starting at the col and row specified\n"
  632.  "and extending to the diagonal corners specified by endcol and endrow.\n"
  633.  "\nThe box will be drawn in the bordercolor and bordertype selected.\n"
  634.  "\nThis function is used by mwind to draw the border and can be called\n"
  635.  "separately to draw a box on the screen without defining a window.";
  636.  
  637.  mwind(2,10,77,23,attr(cyan,black),attr(black,green),dtpbrdr);
  638.  wtitle(center,top,attr(black,green)," MBOX ");
  639.  pwindf(0,1,attr(yellow,black),"%s",mboxmsg);
  640.  waitkey(PRET);
  641. }
  642.  
  643. shtitle()
  644. {
  645. char *titlemsg;
  646.  titlemsg=
  647.   "CALL: wtitle(justify, loc, color, \"TITLE\");\n"
  648.   "Where justify= center,  left,  right.\n"
  649.   "      loc    = top,     bottom\n"
  650.   "      color  = any legal FG/BG color combination\n"
  651.   "      TITLE = any string enclosed in quotes\n"
  652.   "\ncenter,left,right,top,bottom are defined in window.h\n"
  653.   "in both upper and lower case.";
  654.  
  655.  mwind(10,7,70,20,attr(cyan,black),attr(yellow,blue),sglbrdr);
  656.  wtitle(center,top,bordercolor," WTITLE ");
  657.  pwindf(0,1,attr(yellow,black),"%s",titlemsg);
  658.  waitkey(PRET);
  659. }
  660.  
  661. shshadow()
  662. {
  663. int y,z;
  664. char *shmsg;
  665. shmsg=
  666.  " There is one special effect\n"
  667.  "available called shadowing. This\n"
  668.  "is set by the global var. (shadow).\n"
  669.  "if shadow=TRUE then shadowing is\n"
  670.  "in effect.";
  671.  shadow=TRUE;
  672.  
  673.  mwind(20,7,59,16,attr(yellow,blue),attr(yellow,red),sldbrdr);
  674.  wtitle(center,top,bordercolor," SHADOW ");
  675.  pwindf(0,1,attr(yellow,blue),"%s",shmsg);
  676.  waitkey(PRET);
  677.  mwind(0,0,79,24,attr(white,blue),attr(white,blue),dblbrdr);
  678.  for(y=2,z=0;z<=15;z+=6) {
  679.    mwind(2,y+z,20,y+3+z,attr(white,red),attr(yellow,red),dtpbrdr);
  680.    pwindfc(1,attr(yellow,blue),"shadow");
  681.    mwind(28,y+z,48,y+3+z,attr(white,red),attr(yellow,red),dtpbrdr);
  682.    pwindfc(1,attr(yellow,blue),"shadow");
  683.    mwind(58,y+z,76,y+3+z,attr(white,red),attr(yellow,red),dtpbrdr);
  684.    pwindfc(1,attr(yellow,blue),"shadow");
  685.  }
  686.  waitkey(PRET);
  687.  for(y=0;y<10;y++)
  688.     rwind();
  689.  shadow = FALSE;
  690. }
  691.  
  692. shattr()
  693. {
  694. char *attrmsg;
  695. attrmsg=
  696.  "  CALL: attr(fg color, bg color);\n"
  697.  "Sets the color attributes. Two global\n"
  698.  "var have been defined in window.h,\n"
  699.  "windowcolor and bordercolor. You can\n"
  700.  "assign these to specific colors\n"
  701.  "i.e.windowcolor=attr(blue,red) or use\n"
  702.  "the attr call directly as in\n"
  703.  "wtitle(left,top,attr(white,red),\"TEST\")";
  704.  
  705.  mwind(20,7,61,18,attr(yellow,blue),attr(yellow,red),sldbrdr);
  706.  wtitle(center,top,bordercolor," ATTR ");
  707.  pwindf(0,1,attr(yellow,blue),"%s",attrmsg);
  708.  waitkey(PRET);
  709. }
  710.  
  711. shgowind()
  712. {
  713. char *gowindmsg;
  714.  gowindmsg=
  715.   "  CALL: gowindcr(int col, int row);     \n"
  716.   "Places the cursor at the col and row    \n"
  717.   "specified. These cordinates are with    \n"
  718.   "respect to the window. i.e.gowindcr(0,0)\n"
  719.   "is the top left corner of the window.     ";
  720.  
  721.  mwind(18,7,65,18,attr(yellow,blue),attr(yellow,red),sldbrdr);
  722.  wtitle(center,top,bordercolor," GOWINDCR ");
  723.  pwindfc(1,attr(yellow,blue),"%s",gowindmsg);
  724.  setcursor(ON);
  725.  gowindcr(0,0);
  726.  putch('L');
  727.  gowindcr(70,0);
  728.  putch('R');
  729.  gowindcr(0,12);
  730.  putch('L');
  731.  gowindcr(70,12);
  732.  putch('R');
  733.  gowindcr(15,6);
  734.  waitkey(PRET);
  735.  setcursor(OFF);
  736. }
  737.  
  738. shmove()
  739. {
  740. char *movmsg;
  741.  movmsg=
  742.   "   CALL: movwind(newcol,newrow);\n"
  743.   "Erases the current window and moves\n"
  744.   "it to the col and row specified.\n"
  745.   "Effects the current window only.\n"
  746.   "Press Return for a demo of the move\n"
  747.   "function.";
  748.  
  749.  mwind(20,7,59,16,attr(yellow,blue),attr(yellow,red),sldbrdr);
  750.  wtitle(center,top,bordercolor," MOVWIND ");
  751.  pwindf(0,1,attr(yellow,blue),"%s",movmsg);
  752.  waitkey(PRET);
  753.  movwind(0,0);
  754.  sleep(1);
  755.  movwind(40,11);
  756.  sleep(1);
  757. }
  758.  
  759. shrwind()
  760. {
  761. char *rwndmsg;
  762.  rwndmsg=
  763.   "       CALL: rwind();\n"
  764.   "Removes last window placed on screen.\n"
  765.   "There must be as many windows removed\n"
  766.   "as their are windows created.\n";
  767.  
  768.  mwind(20,7,59,16,attr(yellow,blue),attr(yellow,red),sldbrdr);
  769.  wtitle(center,top,bordercolor," RWIND ");
  770.  pwindf(0,1,attr(yellow,blue),"%s",rwndmsg);
  771.  waitkey(PRET);
  772. }
  773.  
  774. shsetcursor()
  775. {
  776. char *setcmsg;
  777. setcmsg=
  778.  "   CALL: setcursor(on/off);\n"
  779.  "\nTurns the cursor on and off.\n"
  780.  "ON and OFF are defined in window.h,\n"
  781.  "in both upper and lower case";
  782.  
  783.  mwind(18,7,59,16,attr(white,blue),bordercolor,dsdbrdr);
  784.  wtitle(center,top,bordercolor," SETCURSOR ");
  785.  pwindf(0,1,attr(white,blue),"%s",setcmsg);
  786.  waitkey(PRET);
  787. }
  788.  
  789. shmwind()
  790. {
  791. char *mwndmsg;
  792. mwndmsg=
  793.  "  CALL: mwind(col,row,endcol,endrow,windowcolor,bordercolor,bordertype);\n"
  794.  "\nDraws a window on the screen starting at the col and row specified\n"
  795.  "and extending to the diagonal corners specified by endcol and endrow.\n"
  796.  "\nThe window will be drawn in the windowcolor with a border of \n"
  797.  "bordercolor.\n\nPress return for bordertypes";
  798.  
  799.  mwind(2,8,77,21,attr(yellow,black),bordercolor,dsdbrdr);
  800.  wtitle(center,top,bordercolor," MWIND ");
  801.  pwindf(0,1,attr(yellow,black),"%s",mwndmsg);
  802.  waitkey(PRET);
  803. }
  804. shinitwindow()
  805. {
  806.  char *iwndmsg;
  807.  
  808.   iwndmsg=
  809.    "         CALL: initwindow();\n"
  810.    "\nThis function must be called before\n"
  811.    "any other routines in this package are\n"
  812.    "used.It sets up the window arrays, video\n"
  813.    "pointers, and checks the enviroment for\n"
  814.    "a define WSNOW=remove. If WSNOW is set\n"
  815.    "in the enviroment then all routines write\n"
  816.    "to the screen using snow supression.";
  817.  
  818.  mwind(18,5,61,18,attr(white,black),bordercolor,dblbrdr);
  819.  wtitle(center,top,bordercolor," INITWINDOW ");
  820.  pwindf(0,1,attr(white,black),"%s",iwndmsg);
  821.  waitkey(PRET);
  822. }
  823.  
  824. shscroll()
  825. {
  826. int x;
  827. char *scrlmsg;
  828.  
  829.  scrlmsg=
  830.  "  With the two print window functions\n"
  831.  "( pwindf and pwindfc ) specifying a row\n"
  832.  "of -1 or a row equal to (var:rowend) cause the\n"
  833.  "window to scroll. In the first case down and\n"
  834.  "the second case up.\n"
  835.  "  A scrolling demo is next. Watch it, the\n"
  836.  "scroll goes fast";
  837.  mwind(18,5,70,18,attr(white,black),bordercolor,dblbrdr);
  838.  wtitle(center,top,bordercolor," SCROllING ");
  839.  pwindf(0,1,attr(white,black),"%s",scrlmsg);
  840.  waitkey(MORE);
  841.  for(x=0;x<=40;x++)
  842.    pwindf(0,rowend,attr(white,black),"scroll line up #%d",x);
  843.  waitkey(PRET);
  844.  for(x=0;x<=40;x++)
  845.    pwindf(0,-1,attr(white,black),"scroll down line #%d",x);
  846.  waitkey(PRET);
  847. }
  848.  
  849.  
  850. shclrscr()
  851. {
  852. char *clrmsg;
  853. clrmsg=
  854.  "CALL:clrscr(attr(FG,BG), bord color);\n"
  855.  "\nClears screen and border to specified\n"
  856.  "color. Will not clear individual\n"
  857.  "windows. The colors are defined in\n"
  858.  "window.h, in both upper and lower\n"
  859.  "case.";
  860.  
  861.  mwind(18,4,59,15,attr(black,green),bordercolor,sldbrdr);
  862.  wtitle(center,top,bordercolor," CLRSCR ");
  863.  pwindf(0,1,attr(black,green),"%s",clrmsg);
  864.  waitkey(PRET);
  865. }
  866.  
  867. shclrwind()
  868. {
  869. char *clrwndmsg;
  870.  clrwndmsg=
  871.  "   CALL: clrwind(color);\n"
  872.  "\nClears current window to\n"
  873.  "selected color.";
  874.  
  875.  mwind(18,5,59,14,attr(yellow,blue),bordercolor,sldbrdr);
  876.  wtitle(center,top,bordercolor," CLRWIND ");
  877.  clrwind(blue);
  878.  pwindf(0,1,attr(yellow,blue),"%s",clrwndmsg);
  879.  waitkey(PRET);
  880. }
  881.  
  882. shscreenmode()
  883. {
  884. char *scrmsg;
  885. scrmsg=
  886.  "   CALL: screenmode(size)\n"
  887.  "\nSets the display screen mode.\n"
  888.  "color80 and color40 are defined\n"
  889.  "in window.h. The window functions\n"
  890.  "support both 80 and 40 col. modes.";
  891.  
  892.  mwind(18,6,59,16,attr(cyan,red),bordercolor,sglbrdr);
  893.  wtitle(center,top,bordercolor," SCREENMODE ");
  894.  pwindf(0,1,attr(cyan,red),"%s",scrmsg);
  895.  waitkey(PRET);
  896. }
  897.  
  898. shborders(void)
  899. {
  900.  int x;
  901.  
  902.  bordercolor=attr(yellow,red);
  903.  windowcolor=attr(white,blue);
  904.  mwind(10,0,72,8,windowcolor,bordercolor,dblbrdr);
  905.  pwindfc(0,windowcolor,"Border selection");
  906.  pwindf(1,1,windowcolor,"1) mwind(10,10,30,14,bordercolor,bordercolor,nobrdr);");
  907.  pwindf(1,2,windowcolor,"2) mwind(32,10,52,14,windowcolor,bordercolor,dblbrdr);");
  908.  pwindf(1,3,windowcolor,"3) mwind(55,10,75,14,windowcolor,bordercolor,sglbrdr);");
  909.  pwindf(1,4,windowcolor,"4) mwind(10,16,30,20,windowcolor,bordercolor,sldbrdr);");
  910.  pwindf(1,5,windowcolor,"5) mwind(32,16,52,20,windowcolor,bordercolor,dtpbrdr);");
  911.  pwindf(1,6,windowcolor,"6) mwind(55,16,75,20,windowcolor,bordercolor,dsdbrdr);");
  912.  mwind(7,10,27,14,bordercolor,bordercolor,nobrdr);
  913.  wtitle(left,top,bordercolor," #1 ");
  914.  pwindfc(1,windowcolor,"No Border");
  915.  mwind(30,10,50,14,windowcolor,bordercolor,dblbrdr);
  916.  wtitle(left,top,bordercolor," #2 ");
  917.  pwindfc(1,windowcolor,"Double Border");
  918.  mwind(53,10,73,14,windowcolor,bordercolor,sglbrdr);
  919.  wtitle(left,top,bordercolor," #3 ");
  920.  pwindfc(1,windowcolor,"Single Border");
  921.  mwind(7,16,27,20,windowcolor,bordercolor,sldbrdr);
  922.  wtitle(left,top,bordercolor," #4 ");
  923.  pwindfc(1,windowcolor,"Solid Border");
  924.  mwind(30,16,50,20,windowcolor,bordercolor,dtpbrdr);
  925.  wtitle(left,top,bordercolor," #5 ");
  926.  pwindfc(1,windowcolor,"Mixed Border");
  927.  mwind(53,16,73,20,windowcolor,bordercolor,dsdbrdr);
  928.  wtitle(left,top,bordercolor," #6 ");
  929.  pwindfc(1,windowcolor,"Mixed Border");
  930.  waitkey(PRET);
  931.  for(x=1;x<=7;x++)
  932.    rwind();
  933. }
  934.  
  935. shpullmenu(char index)
  936. {
  937.  char *usedef,*retcdef,*opdef,*exitdef,*pullsyn,*menudef;
  938.  
  939.  usedef=
  940.   "  This is one way to use the character returned from the popupmenu\n"
  941.   "function. This is part of the routine used in this program\n"
  942.   "\nchar index;\n"
  943.   "\nwhile((index = pullmenu(TOP,0) != NULL)\n"
  944.   " switch(pullmenuloc)\n"
  945.   " {\n"
  946.   "   case 0:  /* The Global var pullmenuloc defines where the hilited\n"
  947.   "               bar was when you hit return. Index is returned from\n"
  948.   "               the function if you were in a sub menu at the time */\n"
  949.   "     switch(index) {\n"
  950.   "        case 'P':\n"
  951.   "           mwind(0,11,79,23,windowcolor,bordercolor,sldbrdr);\n"
  952.   "           wtitle(CENTER,TOP,bordercolor,\" POPUPMENU SYNTAX \");\n"
  953.   "           pwindfc(0,windowcolor,\"CALLING CONVENTION\");\n"
  954.   "           pwindf(0,1,windowcolor,\"%s\",popsyn);\n"
  955.   "           waitkey(PRET);\n"
  956.   "           rwind();\n"
  957.   "        break;\n"
  958.   "     }\n"
  959.   " }\n";
  960.  
  961.   retcdef=
  962.    "   The pull menu routine returns to the calling function with\n"
  963.    "the character of the SUB menu item you selected.\n"
  964.    "   For example if you select Defining a Menu the \"D\" is returned\n"
  965.    "to the calling function and pullmenuloc is set to 0";
  966.  
  967.   opdef=
  968.    "  To operate the menu, you use the left or right arrow keys\n"
  969.    "to move the hilited bar and the enter key or down arrow\n"
  970.    "to enter a SUB menu or make the selection. You may also\n"
  971.    "enter the hilited character to make your selection\n";
  972.  
  973.   exitdef=
  974.    "  If you are in a SUB menu and hit \" ESC \" you will return to the \n"
  975.    "Main pull down menu or the calling function with a return value of\n"
  976.    "NULL.";
  977.   pullsyn =
  978.         "pullmenu(location,menunum);\n"
  979.         "\n WHERE:\n"
  980.         "         location is TOP or BOTTOM\n"
  981.         "         menunum is the number of the main menu (0 to 7)\n";
  982.  
  983.   menudef=
  984.         "pullmainmenu =                     Initilize pointer.\n"
  985.         "\"inTro\\n\"                       Define all menu selections\n"
  986.         "\"Initilize\\n\"                   You can have up to seven (7)\n"
  987.         "\"Screen\\n\"                      menu selections\n"
  988.         "\"Windows\\n\" \n"
  989.         "\"Printing\\n\" \n"
  990.         "\"pOp Wind\\n\" \n"
  991.         "\"Next Menu\\n\" \n"
  992.         "\"TISWPON\\n\"  \n"
  993.         "\n  The last line of menu definition defines the characters that\n"
  994.         "can be directly entered to select an item from the menu, these must\n"
  995.         "be all CAPS. All the characters in this last line must also be\n"
  996.         "distinct. The coresponding letter in each menu selection must also\n"
  997.         "be in CAPS.\n"
  998.         "\n  For example the last line in this menu is \"TISWPON\" this\n"
  999.         "coresponds to the T in \"inTro\", the I in \"Initilize\",\n"
  1000.         "the S in \"Screen\", the W in \"windows\" and ....\n";
  1001.  
  1002.     switch(index)
  1003.     {
  1004.      case 'P':
  1005.         mwind(0,11,79,23,windowcolor,bordercolor,sldbrdr);
  1006.         wtitle(CENTER,TOP,bordercolor," PULLMENU SYNTAX ");
  1007.         pwindfc(0,windowcolor,"CALLING CONVENTION");
  1008.         pwindf(0,1,windowcolor,"%s",pullsyn);
  1009.         waitkey(PRET);
  1010.         rwind();
  1011.         break;
  1012.       case 'D':
  1013.         mwind(0,0,79,24,windowcolor,bordercolor,sldbrdr);
  1014.         wtitle(CENTER,TOP,bordercolor," MENU DEFINITION ");
  1015.         pwindfc(0,windowcolor,"MENU SETUP");
  1016.         pwindf(0,1,windowcolor,"%s",menudef);
  1017.         waitkey(PRET);
  1018.         rwind();
  1019.         break;
  1020.       case 'M':
  1021.         mwind(0,9,79,16,windowcolor,bordercolor,sldbrdr);
  1022.         wtitle(CENTER,TOP,bordercolor," OPERATING MENU ");
  1023.         pwindf(0,1,windowcolor,"%s",opdef);
  1024.         waitkey(PRET);
  1025.         rwind();
  1026.         break;
  1027.       case 'R':
  1028.         mwind(0,9,79,16,windowcolor,bordercolor,sldbrdr);
  1029.         wtitle(CENTER,TOP,bordercolor," RETURN CODE ");
  1030.         pwindf(0,1,windowcolor,"%s",retcdef);
  1031.         waitkey(PRET);
  1032.         rwind();
  1033.         break;
  1034.       case 'U':
  1035.         mwind(0,0,79,24,windowcolor,bordercolor,sldbrdr);
  1036.         wtitle(CENTER,TOP,bordercolor," PROGRAM SETUP ");
  1037.         pwindf(0,1,windowcolor,"%s",usedef);
  1038.         waitkey(PRET);
  1039.         rwind();
  1040.         break;
  1041.       case 'E':
  1042.         mwind(0,10,79,14,windowcolor,bordercolor,sldbrdr);
  1043.         wtitle(CENTER,TOP,bordercolor," EXITING MENU ");
  1044.         pwindfc(0,windowcolor,"EXITING MENU WITHOUT A SELECTION");
  1045.         pwindf(0,1,windowcolor,"%s",exitdef);
  1046.         waitkey(PRET);
  1047.         rwind();
  1048.         break;
  1049.     }
  1050. }